From 312caab05a956769150d186fa170f89ca3a945e6 Mon Sep 17 00:00:00 2001
From: Hal Emmerich <hal@halemmerich.com>
Date: Wed, 11 Dec 2019 21:33:42 -0600
Subject: [PATCH] Add VbDisplayInfo struct in context

Allows for access of the debug info from the context struct, useful for VbDisplayScreen
---
 firmware/2lib/include/2api.h | 11 +++++++++++
 firmware/lib/vboot_ui.c      | 12 ++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/firmware/2lib/include/2api.h b/firmware/2lib/include/2api.h
index 97b5cca6..fdcc3a1e 100644
--- a/firmware/2lib/include/2api.h
+++ b/firmware/2lib/include/2api.h
@@ -166,6 +166,15 @@ enum vb2_context_flags {
 	VB2_CONTEXT_SW_WP_ENABLED = (1 << 18),
 };
 
+/* Information on display context */
+typedef struct VbDisplayInfo {
+	uint32_t allow_usb;
+	uint32_t allow_legacy;
+	uint32_t use_usb;
+	uint32_t use_legacy;
+	uint32_t signed_only;
+} VbDisplayInfo;
+
 /*
  * Context for firmware verification.  Pass this to all vboot APIs.
  *
@@ -176,6 +185,8 @@ struct vb2_context {
 	 * Fields which must be initialized by caller.
 	 */
 
+	VbDisplayInfo info;
+
 	/*
 	 * Flags; see vb2_context_flags.  Some flags may only be set by caller
 	 * prior to calling vboot functions.
diff --git a/firmware/lib/vboot_ui.c b/firmware/lib/vboot_ui.c
index 5f891013..d248eb3e 100644
--- a/firmware/lib/vboot_ui.c
+++ b/firmware/lib/vboot_ui.c
@@ -177,6 +177,9 @@ VbError_t vb2_developer_ui(struct vb2_context *ctx)
 	/* Check if the default is to boot using disk, usb, or legacy */
 	uint32_t default_boot = vb2_nv_get(ctx, VB2_NV_DEV_DEFAULT_BOOT);
 
+	/* Check if unsigned booting is allowed */
+	uint32_t signed_only = vb2_nv_get(ctx, VB2_NV_DEV_BOOT_SIGNED_ONLY);
+
 	if(default_boot == VB2_DEV_DEFAULT_BOOT_USB)
 		use_usb = 1;
 	if(default_boot == VB2_DEV_DEFAULT_BOOT_LEGACY)
@@ -207,6 +210,15 @@ VbError_t vb2_developer_ui(struct vb2_context *ctx)
 		}
 	}
 
+	if (ctx->flags & FWMP_DEV_ENABLE_OFFICIAL_ONLY)
+		signed_only = 1;
+
+	ctx->info.allow_usb = allow_usb;
+	ctx->info.allow_legacy = allow_legacy;
+	ctx->info.use_usb = use_usb;
+	ctx->info.use_legacy = use_legacy;
+	ctx->info.signed_only = signed_only;
+
 	/* If dev mode is disabled, only allow TONORM */
 	while (disable_dev_boot) {
 		VB2_DEBUG("dev_disable_boot is set\n");
-- 
2.20.1

